<extend name="Base/common" />
<block name="Content">
    <div class="am-cf am-padding-top">
        <div class="am-fl am-cf">
            <i class="am-icon-file"></i>
            <strong class="am-text-primary am-text-lg">订单管理</strong>
        </div>
        <hr data-am-widget="divider" class="am-divider am-divider-default" />
    </div>
   
        <div class="am-u-sm-12 am-u-md-6" style="padding:0px">
            <div class="am-btn-toolbar">
                <div class="am-btn-group am-btn-group-xs">
                    <a class="am-btn am-btn-success" href="{:U('editAction')}">
                    	<span class="am-icon-plus"></span>&nbsp;新增
                    </a>
                </div>
            </div>
        </div>
       	<div class="am-fr am-padding-right am-u-md-3">
			<a class="am-margin-top-sm am-btn am-btn-primary am-btn-xs am-fr" id="high-class"> 
				<i class="am-icon-search"></i>&nbsp;&nbsp;高级查询
			</a>
		</div>
  
    <table class="am-table am-table-striped am-table-hover table-main">
        <thead>
            <tr>
            	<th class="table-title am-text-left" style="width:9%">
                    小哥信息
                </th>
                <th class="table-title am-text-left" style="width:13%">
                    维修地址
                </th>
                <th class="table-title am-text-left" style="width:10%">
                    服务分类
                </th>
                <th class="table-title am-text-left" style="width:6%">
                    订单类型
                </th>
                <th class="table-title am-text-left" style="width:6%">
                    下单时间
                </th>
                <th class="table-title am-text-left" style="width:10%">
                    服务时间
                </th>
                <th class="table-title am-text-left" style="width:6%">
                    服务时长
                </th>
                <th class="table-title am-text-left" style="width:10%">
                    订单状态
                </th>
                <th class="table-title am-text-left" style="width:5%">
                    付款方式
                </th>
                <th class="table-title am-text-left" style="width:5%">
                    交易额
                </th>
                <th class="table-set am-text-left" style="width:20%">
                    操作
                </th>
            </tr>
        </thead>
        <tbody>
            <notempty name="list">
                <foreach name="list" item="order">
                    <tr>
                    	<td>
                            {$order.name}/{$order.eid}
                        </td>
                        <td>
                            {$order.address}
                        </td>
                        <td>
                            {$detailList[$order['detail_id']]['detail_name']}
                        </td>
                        <td>
                            <eq name="order.emergency" value="1">预约服务<else/>紧急服务</eq>
                        </td>
                        <td>
                            {$order.create_time|GetDateMk}
                        </td>
                        <td>
                        	<if condition="$order.emergency eq '2'">
                            	{$order.delay|default='0'} 分钟
                            <else/>
                            	{$order.appointment|date='Y-m-d H:i',###}
                            </if>
                        </td>
                        <td>
                            {$order.service_time} 分钟
                        </td>
                        <td>
                            <switch name="order.status">
                            	<case value="1">
                            		新下订单
                           		</case>
                            	<case value="2">
                            		小哥已抢单
                           		</case>
                            	<case value="3">
                            		正在服务
                           		</case>
                            	<case value="4">
                            		待收费
                           		</case>
                            	<case value="5">
                            		现金付款待确认
                           		</case>
                            	<case value="6">
                            		订单已结束待评价
                           		</case>
                            	<case value="7">
                            		订单已取消
                           		</case>
                            	<case value="8">
                            		已转（派）单，待小哥确认
                           		</case>
                            	<case value="9">
                            		已评价
                           		</case>
                           	</switch>
                        </td>
                        <td>
                        	<if condition="$order.pay_type eq '1'">
                        		微信
                        	<elseif  condition="$order.pay_type eq '2'"/>
                        		现金
                        	</if>
                        </td>
                        <td>
                            {$order.turnover}
                        </td>
                        <td>
                            <div class="am-btn-toolbar">
                                <div class="am-btn-group am-btn-group-xs">
                                    <a class="am-btn am-btn-default am-btn-xs am-text-secondary" 
                                    	href="{:U('viewAction?order_id='.$order['order_id'])}">
                                    	<span class="am-icon-pencil-square-o"></span>详情
                                    </a>
                                    <!-- 1：新下单；2：已分配小哥； -->
                                    <in name="order.status" value="1,2,8">
                                    	<a class="am-btn am-btn-default am-btn-xs am-text-secondary" 
                                    		onclick="order('{$order.order_id}')">
	                                    	<span class="am-icon-pencil-square-o"></span>改（派）单
	                                    </a>
	                                    <a class="am-btn am-btn-default am-btn-xs am-text-danger am-hide-sm-only ajax-get confirm" 
	                                    	href="{:U('cancel?order_id='.$order['order_id'].'&w_contact='.$w_contact)}">
	                                    	<span class="am-icon-trash-o"></span>取消
	                                    </a>
                                    </in>
                                </div>
                            </div>
                        </td>
                    </tr>
                </foreach>
                <else/>
                <td colspan="15" class="text-center">
                    aOh! 暂时还没有内容!
                </td>
            </notempty>
        </tbody>
    </table>
    <!-- 分页 -->
    <ul class="am-pagination am-pagination-default am-no-layout amz-social">
        {$_page}
    </ul>
    <!-- /分页 -->
    
    <include file="Orders/searchModal"/>
    <include file="Orders/orderModal"/>
    
</block>
<block name="style">
    <style type="text/css">
        .am-table {
            padding-left: 0px;
            margin-left: 0px
        }
    </style>
</block>
<block name="script">
<script type="text/javascript">
    $(function(){
    	
    	//弹出模态框
        $("#high-class").click(function(){
        	$('#order-search').modal({
        		relatedTarget: this,
                closeViaDimmer: 0,
            });
        })
    });
    
  	//派单时只派给自有团队成员，且需小哥在用户预约时间有空
	function order(orderID){
		
		orderID = parseInt(orderID);
		var target = Think.U('Orders/memberList');
		
		$.post(target,{'order_id':orderID},function(data){
    		if(data.status==1){
    			
    			var html = "";
    			
    			$.each(data.info, function(key, val){
					
    				html += '<option value="' + val['worker_id'] + '">' + val['name'] + '</option>';
    			});
    			
    			$("#worker").html(html);
    			$("#order_id").val(orderID);
    			
    			$('#order-operation').modal({
            		relatedTarget: this,
                    closeViaDimmer: 0,
                });
			}
    	});
	}
	
</script>
</block>
